<template>
  <JsMind :mindData="mindData" />
</template>

<script>
import JsMind from "./components/index.vue";
import { mindData, mindData1 } from "./mock";

export default {
  name: "JsMind1",
  components: {
    JsMind,
  },
  data() {
    return {
      mindData: null,
    };
  },
  mounted() {
    this.mindData = mindData;

    this.init();
  },
  methods: {
    init() {
      const originData = [
        {
          unit: "ff5cb3c8d6d641b1af0e3af6db9dfb45|03011M",
          dimensionScore: "A",
          name: "1F",
          evaluationTarget: "xxx系统",
          equipmentName: "向家坝1F水轮发电机组",
        },
        {
          unit: "ff5cb3c8d6d641b1af0e3af6db9dfb45|03082M",
          dimensionScore: "C",
          name: "8F",
          evaluationTarget: "xxx系统",
          equipmentName: "向家坝8F水轮发电机组",
        },
      ];
      const mindData = this.resetData("监控系统", originData);
      this.mindData = mindData;
    },
    resetData(title, originData) {
      originData.sort((a, b) => parseInt(a.name) - parseInt(b.name));
      const returnObj = {
        id: 11408,
        noteName: title,
        level: 0,
        fraction: 100,
        score: "A",
        type: "维度",
        children: [],
      };

      returnObj.children = originData.map((item, index) => {
        return {
          id: index + 100,
          noteName: item.name,
          level: 1,
          fraction: 100,
          score: item.dimensionScore,
          type: "维度",
          direction: index % 2 === 0 ? "left" : "right",
        };
      });

      return returnObj;
    },
  },
};
</script>

<style lang="scss" scoped></style>
